<?php
// The usual - init a curl session and set the url
$username = $_GET["username"];
$password = $_GET["password"];
$url = $_GET["url"];
$title = $_GET["title"];
$tags = $_GET["tags"];

$base_url = "https://api.del.icio.us/v1/posts/add?url=".rawurlencode($url)."&description=".rawurlencode($title)."&tags=".rawurlencode($tags);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $base_url);

// Set your login and password for authentication
curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// Optional: Return the result instead of printing it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// The usual - get the data and close the session
$data = curl_exec($ch);
$header = curl_getinfo($ch);
curl_close($ch); 

header("Content-Type: text/xml", true, $header["http_code"]);
echo $data;
?>